/**
 * 
 */
package com.google.code.sip.ucenter.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Property;
import com.google.code.morphia.annotations.Reference;

/**
 * @author Liuye
 * 
 */
@Entity(noClassnameStored = true)
@SuppressWarnings("serial")
public class UserCount extends BaseEntity {
	/**
	 * 用户
	 */
	@Reference
	private User user;

	/**
	 * 积分
	 */
	@Reference
	private List<Credit> credits = new ArrayList<Credit>();

	@Property
	private Map<String, Integer> counts = new HashMap<String, Integer>();

	/**
	 * 总积分
	 */
	private int creditCount = 0;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public int getCreditCount() {
		return creditCount;
	}

	public void setCreditCount(int creditCount) {
		this.creditCount = creditCount;
	}

	public List<Credit> getCredits() {
		return credits;
	}

	public void setCredits(List<Credit> credits) {
		this.credits = credits;
	}

	public Map<String, Integer> getCounts() {
		return counts;
	}

	public void setCounts(Map<String, Integer> counts) {
		this.counts = counts;
	}

	public int getCount(String name) {
		Integer count = counts.get(name);
		return count != null ? count : 0;
	}

	public void addCount(String name, int count) {
		counts.put(name, count);
	}
}
